<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>重复发送请求</title>
</head>
<body>
<button class="send">点击发送</button>
<script>
  var send = document.querySelector('.send');
  var xhr = new XMLHttpRequest();
  //定义一个是否发送中的变量
  var isSending = false;
  send.onclick = function () {
    //如果正在发送让其取消
    if (isSending) xhr.abort();
    xhr.open('GET','http://localhost:8000/delay');
    xhr.send();
    if (xhr.readyState == 4) {
      isSending = true;
    }
  }
</script>
</body>
</html>